package com.logos.servlet.rep;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/respRedirect1")
public class ResponseRedirectTest1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("ResponseRedirectTest1.doGet");

        // 重定向
        // 1.设置响应状态码 302
//        resp.setStatus(302);
        // 2.设置响应头 Location
//        resp.setHeader("Location", "/resp2");

        // 简化方式完成重定向
        resp.sendRedirect("/respRedirect2");

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
